<template>
  <div class="bottom-box">
      <div class="flex-box">
        <div class="item" v-for="(item, key) in nav_list" :key="key" @click="setPage(key)" :class="{'active': active_index == key}">
          <div class="icon-svg" :class="item.icon"></div>
          <div class="grid-cell">{{ item.title }}</div>
        </div>
      </div>
  </div>
</template>

<script>
export default {
  name: "BottomNav",
  data() {
    return {
      active_index: 0,
      nav_list: [
        {
          path: '/',
          icon: 'svg-x-like',
          title: '推荐'
        },
        // {
        //   path: '/care',
        //   icon: 'svg-x-qiu',
        //   title: '关注'
        // },
        {
          path: '/bbs',
          icon: 'svg-x-lanmu',
          title: '论坛'
        },
        {
          path: '/my',
          icon: 'svg-x-kf',
          title: '个人'
        }
      ]
    };
  },
  methods: {
    setPage(key) {
      this.active_index = key;
      this.$router.replace({
        path: this.nav_list[key].path
      });
      
    }
  }
};
</script>
<style scoped lang="less">
.bottom-box {
  position: relative;
  box-shadow: 0 3px 5px #000;
}
.flex-box {
  background: #FFFFFF;
  color: #333;
  display: flex;
  align-items: center;
  height: 50px;
  .item {
    position: relative;
    display: flex;
    flex-direction: column;
    height: 100%;
    justify-content: center;
    flex: 1;
    text-align: center;
    * {
      transition: color .3s, font-size .3s;
    }
    .grid-cell {
      font-weight: 700;
      line-height: 20px;
      font-size: 12px;
    }
    &.active {
      color: #2196f3;
      .grid-cell {
        font-size: 13px;
      }
    }
  }
}
.icon-svg {
  margin: auto;
  width: 24px;
  height: 24px;
  background-image: '';
  background-repeat: no-repeat;
  background-position: center;
  background-size: 100% 100%;
}

.svg-x-like {
  background-image: url('../../assets/svg/x/like.svg');
}

.svg-x-lanmu {
  background-image: url('../../assets/svg/x/lanmu.svg');
}

.svg-x-message {
  background-image: url('../../assets/svg/x/message.svg');
}

.svg-x-user {
  background-image: url('../../assets/svg/x/user.svg');
}

.svg-x-hg {
  background-image: url('../../assets/svg/x/hg.svg');
}
.svg-x-qiu {
  background-image: url('../../assets/svg/x/qiu.svg');
}
.svg-x-kf {
  background-image: url('../../assets/svg/x/kf.svg');
}
</style>
